import { Application } from "pinus";
import { PlayerInfo } from "./playerInfo";
import { ISrvMod } from "../../common/iservices";


export class PlayerInfoMgr {
    private app: Application;
    private players: ISrvMod.Dic<PlayerInfo> = {};    // 所有玩家数据

    constructor(app: Application) {
        this.app = app;
        setInterval(this.checkDelRole.bind(this), 1200 * 1000);
    }

    /**
     * 玩家登录游戏
     * @param uid 
     */
    async enterServer(): Promise<void> {

    }

    /**
     * 重连
     */
    async reconnectEntry(uid: number, sid: string, token: number): Promise<void> {

    }


    // 检测过期玩家，删除缓存数据
    private checkDelRole() {

    }

    private delRole(uid: number) {
        const role = this.players[uid];
        if (!role) {
            return;
        }
        delete this.players[uid];
    }

    /**
     * 获取玩家信息
     */
    getRole(uid: number) {
        return this.players[uid];
    }
}

